<!--
    group: 企业管理
    name: 企业入驻----填写企业信息
    url: /enterprise/modules/enterpriseSettled
-->
<template>
  <div class="enterpriseSettled-con">
    <h3>企业基本信息</h3>

    <a-form-model :model="form" ref="ruleForm" :rules="rules"
                  :label-col="labelCol" :wrapper-col="wrapperCol"
    >
<!--      <a-form-model-item label="注册类型" prop="resource" class="radioGroup">-->
<!--        &lt;!&ndash; 企业类型 1-个体工商户 2-有限公司 3-合伙企业 4-个人独资企业&ndash;&gt;-->
<!--        <a-radio-group v-model="form.resource">-->
<!--          <a-radio :value="1">个体工商户</a-radio>-->
<!--          &lt;!&ndash;<a-radio :value="4">个人独自企业</a-radio>&ndash;&gt;-->
<!--        </a-radio-group>-->
<!--      </a-form-model-item>-->
<!--      <a-form-model-item label="企业服务模式" prop="serviceConfId" class="radioGroup">-->
<!--        <a-radio-group v-model="form.serviceConfId">-->
<!--          <a-radio :value="1">月开票15万以内</a-radio>-->
<!--          <a-radio :value="2">月开票15万及以上</a-radio>-->
<!--        </a-radio-group>-->
<!--      </a-form-model-item>-->
<!--      <a-form-model-item label="组织形式" prop="organizationForm">
        <a-select v-model="form.organizationForm" placeholder="请选择">
          <a-select-option v-for="item in organizational" :value="item.itemValue">{{ item.itemText }}</a-select-option>
        </a-select>
      &lt;!&ndash;<j-dict-select-tag v-model="form.organizationForm" placeholder="请选择" dictCode="organizational"/>&ndash;&gt;
      </a-form-model-item>-->
      <a-form-model-item prop="money" label="注册资金">
        <a-input-number v-model="form.money" step="2" :min="1" :max="200" :precision="0" :formatter="limitNumber" :parser="limitNumber"  />&nbsp;万元
      </a-form-model-item>

      <a-form-model-item label="经营范围">
        <span class="addRange" @click="addNatureBusiness"><a-icon type="plus" />添加经营范围</span>
      </a-form-model-item>
      <JYFWNew ref="child" :optionList="newTreeData" :masterDataSource="masterDataSource" v-model="newTreeDataModel" :defaultValue="newTreeDatadefaultModel" :getDataEvent="getDataEvent_" />

<!--      <template v-for="(item,index) in form.business" :index="index">-->
<!--        <a-form-model-item label="主营业务经营类别" required>-->
<!--          <a-cascader-->
<!--            v-model="item.manageId"-->
<!--            :options="treeData"-->
<!--            placeholder="请选择"-->
<!--            @change="action => handleProvinceChange(action, index)"-->
<!--            :field-names="fieldOptions"-->
<!--          />-->
<!--          <a-button type="link" icon="minus" class="minus"-->
<!--                    style="color: #cc0000;"-->
<!--                    v-if="index != 0"-->
<!--                    @click="deleteRateFun(index)"-->
<!--          >删除经营范围-->
<!--          </a-button>-->
<!--        </a-form-model-item>-->
<!--        <a-form-model-item label="经营活动">-->
<!--          <a-input v-model="item.nodeNature" type="textarea" disabled />-->
<!--        </a-form-model-item>-->
<!--        <a-form-model-item label="开票类目">-->
<!--          <a-input v-model="item.invoiceName" type="textarea" disabled />-->
<!--        </a-form-model-item>-->
<!--      </template>-->

      <a-form-model-item label="企业名称1" required>
        <div class="entNames">
          <a-form-model-item prop="entName1Short">
            <a-input stype="input" v-model="form.entName1Short" placeholder="请输入企业名称1" >
              <a-select slot="addonBefore" default-value="请选择" @change="onChangeLabel">
                <a-select-option v-for="(item, key) in dictOptions" :key="key" :value="item.value">
                  {{ item.label }}
                </a-select-option>
              </a-select>
              <span slot="addonAfter">
                <a-select v-model="form.labelOrgnameId1">
                  <a-select-option v-for="(item, key) in form.business[0].labelOrgname" :key="key" :value="item.id">{{ item.value }}</a-select-option>
                </a-select>
                {{{0:'工作室',1:'部',2:'中心'}[form.organizationForm] || ''}}
              </span>
            </a-input>
          </a-form-model-item>
        </div>
      </a-form-model-item>
      <a-form-model-item label="企业名称2" required>
        <div class="entNames">
          <a-form-model-item prop="entName2Short">
            <a-input type="input" v-model="form.entName2Short" placeholder="请输入企业名称2" >
              <span slot='addonBefore'>{{{0:'荆州市沙市区',1:'沙市区'}[form.areaPre] || ''}}</span>
              <span slot="addonAfter">
                <a-select v-model="form.labelOrgnameId2">
                  <a-select-option v-for="(item, key) in form.business[0].labelOrgname" :key="key" :value="item.id">{{ item.value }}</a-select-option>
                </a-select>
                {{{0:'工作室',1:'部',2:'中心'}[form.organizationForm] || ''}}
              </span>
            </a-input>
          </a-form-model-item>
        </div>
      </a-form-model-item>
      <a-form-model-item label="企业名称3" required>
        <div class="entNames">
          <a-form-model-item prop="entName3Short">
            <a-input type="input" v-model="form.entName3Short" placeholder="请输入企业名称3">
              <span slot='addonBefore'>{{{0:'荆州市沙市区',1:'沙市区'}[form.areaPre] || ''}}</span>
              <span slot="addonAfter">
                <a-select v-model="form.labelOrgnameId3">
                  <a-select-option v-for="(item, key) in form.business[0].labelOrgname" :key="key" :value="item.id">{{ item.value }}</a-select-option>
                </a-select>
                {{{0:'工作室',1:'部',2:'中心'}[form.organizationForm] || ''}}
              </span>
            </a-input>
          </a-form-model-item>
        </div>
      </a-form-model-item>
      <a-form-model-item label="企业名称4" required>
        <div class="entNames">
          <a-form-model-item prop="entName4Short">
            <a-input type="input" v-model="form.entName4Short" placeholder="请输入企业名称4" >
              <span slot='addonBefore'>{{{0:'荆州市沙市区',1:'沙市区'}[form.areaPre] || ''}}</span>
              <span slot="addonAfter">
                <a-select v-model="form.labelOrgnameId4">
                  <a-select-option v-for="(item, key) in form.business[0].labelOrgname" :key="key" :value="item.id">{{ item.value }}</a-select-option>
                </a-select>
                {{{0:'工作室',1:'部',2:'中心'}[form.organizationForm] || ''}}
              </span>
            </a-input>
          </a-form-model-item>
        </div>
      </a-form-model-item>
      <a-form-model-item label="企业名称5" required>
        <div class="entNames">
          <a-form-model-item prop="entName5Short">
            <a-input type="input" v-model="form.entName5Short" placeholder="请输入企业名称5">
              <span slot='addonBefore'>{{{0:'荆州市沙市区',1:'沙市区'}[form.areaPre] || ''}}</span>
              <span slot="addonAfter">
                <a-select v-model="form.labelOrgnameId5">
                  <a-select-option v-for="(item, key) in form.business[0].labelOrgname" :key="key" :value="item.id">{{ item.value }}</a-select-option>
                </a-select>
                {{{0:'工作室',1:'部',2:'中心'}[form.organizationForm] || ''}}
              </span>
            </a-input>
          </a-form-model-item>
        </div>
      </a-form-model-item>
      <a-form-model-item label="" class="alert" :wrapper-col="{ span: 14, offset: 5 }">
        <a-alert message="为避免企业重名或不合规导致注册失败，请提供5个备选企业名称，自动生成的企业名称仅供参考，具体能否通过工商系统核名以实际办理结果为准。" type="info" show-icon />
      </a-form-model-item>
      <a-form-model-item label="" :wrapper-col="{ span: 6, offset: 16 }">
        <a-button type="primary" @click="autoGenerate">自动生成</a-button>
      </a-form-model-item>

      <h3>经营者关联信息查询</h3>
      <QueryOperatorRelatedInformation v-model="qoriConfig.list" :defaultValue="qoriConfig.defaultList" :disabled="qoriConfig.disabled" :model="qoriConfig.model" :defaultLayout="qoriConfig.defaultLayout" :DisplayWizard="false" ></QueryOperatorRelatedInformation>

      <h3 v-if="form.protocolType=='2'">账户信息</h3>
      <CorporateAccountInformation v-if="form.protocolType=='2'" v-model="caiConfig.value" :disabled="caiConfig.disabled" :model="caiConfig.model" :defaultLayout="caiConfig.defaultLayout"  :legalInfo="{legalName:formData.legalInfo.legalName,cardNumber:formData.legalInfo.cardNumber}"></CorporateAccountInformation>



      <h3>企业邮寄地址<span class="red" style="font-weight: normal;font-size: 16px;">（用于向您寄送营业执照等相关证件）</span></h3>
      <a-form-model-item label="收件地址">
        <a-input v-model="form.mailUserAddress" placeholder="请输入收件地址" />
      </a-form-model-item>
      <a-form-model-item label="收件人">
        <a-input v-model="form.mailUserName" placeholder="请输入收件人" />
      </a-form-model-item>
      <a-form-model-item label="手机号" prop="mailUserPhone">
        <a-input v-model="form.mailUserPhone" placeholder="请输入手机号" />
      </a-form-model-item>

      <a-form-model-item :wrapper-col="{ span: 14, offset: 6 }">
        <a-button type="primary" @click="nextStep">下一步</a-button>
<!--        <a class="mLeft" @click="prevStep">返回上一步</a>-->
      </a-form-model-item>
    </a-form-model>

    <!--提示经营范围有误-->
    <a-modal
      v-model="businessInfo.visible"
      :footer="null" :closable="false"
      :keyboard="false"
      :maskClosable="false"
    >
      <div class="exceedLimit">
        <h4>
          <a-icon type="exclamation-circle" theme="filled" />
          {{ businessInfo.message }}
        </h4>
        <div class="desc_btn">
          <a-button type="primary" @click="backEdit">返回修改</a-button>
        </div>
      </div>
    </a-modal>

  </div>
</template>

<script>
import '@/utils/rem'  //rem
import '@/assets/css/enterprise.less'  //css
import {
  conversionManyBranch,cloneObject,limitDigits,carriedParameters,
  filterNull,filterNullArr
} from '@/utils/util'
import { getManageNature, queryEntNames,queryEntInfo } from '@/api/enterprise'
import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
import enterpriseList from '@/api/enterprise.json'
// import JYFWNew from '../../common/JYFWNew'
import JYFWProEvent from '../../common/utils/JYFWPro'
import JYFWNew from '../../common/JYFWPro'
import QueryOperatorRelatedInformation from './../../enterprise/components/QueryOperatorRelatedInformation.vue'
import CorporateAccountInformation from './../../enterprise/components/CorporateAccountInformation.vue'
export default {
  name: 'enterpriseSettled',
  components:{JDictSelectTag,JYFWNew,QueryOperatorRelatedInformation,CorporateAccountInformation},
  props: ['channelId','undertakeData','formData'],
  data(){
    return{
      // 账户信息  wrapperCol: { span: 23, offset: 1 }
      caiConfig:{
        defaultLayout:{labelCol: { span: 5 }, wrapperCol: { span: 17 }},
        value:{}, // {'userName2':'ssss','userName3':'dddd'},
        disabled:false, // edit 状态下可用
        model:'edit', // view 表示预览模式  edit  表示可编辑模式 默认值
        legalInfo:{} // 法人信息 {name:'', phone:'', cardNum:''}
      },
      // 经营者关联信息查询
      qoriConfig:{
        defaultLayout:{ columnNum: 1, labelCol: { span: 0 }, wrapperCol: { span: 20 , offset: 2 }},
        list:{},
        disabled:false, // edit 状态下可用
        model:'', // view 表示预览模式  edit  表示可编辑模式 默认值
        // 经营者关联信息查询  编辑回显值
        defaultList: {}, //{'userName2':{url:'https://zxcloud-test.oss-cn-hangzhou.aliyuncs.com/user/license/1688540243642_%E5%8A%9E%E5%85%AC.png',name:''},'userName3':{url:'https://zxcloud-test.oss-cn-hangzhou.aliyuncs.com/user/license/1688540248058_%E5%8C%97%E4%BA%AC2.png',name:''}},
      },
      labelCol: { span: 5 },
      wrapperCol: { span: 18 },
      organizational: enterpriseList.organizational,
      dictOptions:[
        {value:'0',label:'荆州市沙市区'},{value:'1',label:'沙市区'}
      ],
      form: {
        // resource: 1,
        // serviceConfId: null,  //企业服务模式
        // registerType: null,  //注册类型
        money: 1,  //注册资金
        entName1Short: '',
        entName2Short: '',
        entName3Short: '',
        entName4Short: '',
        entName5Short: '',
        labelOrgnameId1:'',
        labelOrgnameId2:'',
        labelOrgnameId3:'',
        labelOrgnameId4:'',
        labelOrgnameId5:'',
        organizationForm:'',
        mailUserAddress:'',
        mailUserName:'',
        mailUserPhone:'',
        areaPre:'',
        business: [{
          nodeNature:'',
          invoiceName:'',
          labelEntname: '',
          labelOrgname: ''
        }]
      },
      rules:{
        resource:[{ required: true, message: '注册类型', trigger: 'change' }],
        organizationForm:[{ required: true, message: '请选择组织形式', trigger: 'change' }],
        money:[{ required: true, message: '请输入注册资金', trigger: 'blur' }],
        entName1Short:[
          { required: true, message: '请输入企业名称', trigger: 'blur' },
          { validator: this.validateEnterprise }
        ],
        entName2Short:[
          { required: true, message: '请输入企业名称', trigger: 'blur' },
          { validator: this.validateEnterprise }
        ],
        entName3Short:[
          { required: true, message: '请输入企业名称', trigger: 'blur' },
          { validator: this.validateEnterprise }
        ],
        entName4Short:[
          { required: true, message: '请输入企业名称', trigger: 'blur' },
          { validator: this.validateEnterprise }
        ],
        entName5Short:[
          { required: true, message: '请输入企业名称', trigger: 'blur' },
          { validator: this.validateEnterprise }
        ],
        mailUserPhone:[
          { required: false, message: '请输入邮寄手机号', trigger: 'blur' },
          { validator: this.validatePhone }
        ],
      },
      treeData: [],  //经营类别
      fieldOptions: {
        label: 'nodeName',
        value: 'id',
        children: 'children',
      },

      //经营范围
      newTreeData:[],
      newTreeDataModel:[],
      newTreeDatadefaultModel:[],
      masterDataSource:[],
      businessInfo:{  //弹层
        visible: false,
        message: '经营范围选择有误！'
      }
    }
  },
  mounted() {
    // this.getBusinessScope()  //获取经营范围
    this.initEvnet() // 获取经营范围
  },
  created() {
    this.form.serviceConfId = carriedParameters(window.location.href,'serviceConfId');
    this.form.registerType = carriedParameters(window.location.href,'registerType');    //注册类型
    this.form.protocolType = carriedParameters(window.location.href,'protocolType');    //企业所属合作模式
    // v-if="form.protocolType=='2'"
  },
  watch:{
    //监听经营范围
    newTreeDataModel: {
      handler(val) {
        if(val && val.length>0){
          const firstItem = val[0]
          this.form.business[0].nodeNature = firstItem.nodeNature;
          this.form.business[0].invoiceName = firstItem.invoiceName;
          this.form.business[0].labelEntname = firstItem.labelEntname;
          this.form.business[0].labelOrgname = firstItem.labelOrgnameList;
          this.form.organizationForm = firstItem.organizationForm;
          // console.log('监听经营范围================',val,firstItem);
          if(firstItem.labelOrgnameList){
            for(var i = 1; i < 6; i++){
              // if(this.form['labelOrgnameId'+i].length<=0){
              //   this.form['labelOrgnameId'+i] = firstItem.labelOrgnameList[0].id;
              // }
              this.form['labelOrgnameId'+i] = firstItem.labelOrgnameList[0].id;
            }
          }
          this.form.manageId = val.map(item=>item.jyfw);
        }

      },
      deep: false,
      immediate: true,
    },
  },
  methods:{
    async initEvnet() {
      this.JYFWProEvent('getDataForJYFWNew',1,4).then(res=>{
        this.masterDataSource = res
      })
      this.JYFWProEvent('getDataForJYFWNew',0,4).then(res=>{
        this.newTreeData=res
      })
    },
    async getDataEvent_(meritoFlag,level,id){
      return await this.JYFWProEvent('getDataForJYFWNew',meritoFlag,level,id)
    },
    JYFWProEvent(type, ...args) {
      return JYFWProEvent(type, this, ...args)
    },
    // 校验手机号
    validatePhone(rule,value,callback){
      let reg = /^(1\d{10})$/;
      if (!value || reg.test(value)){
        callback();
      }else{
        callback("您的手机号码格式不正确!");
      }
    },
    //下一步
    nextStep(){
      // 经营范围校验
      let res = this.$refs['child'].getVerificationRes()
      console.log('经营范围校验================》',res);
      if(this.caiConfig.value.isAllEmpty == false && this.caiConfig.value.AVRes == false ){
        this.$message.warning('如果您填写了【账户信息】，请进行【账户信息核验】；如果不需要，请清空【账户信息】数据！')
        res = false
        return res
      }
      this.$refs.ruleForm.validate(valid => {
        console.log( '校验结果================》',valid,res);
        if (valid && res==true) {
          let params = {};
          let paramsNew = cloneObject(this.form);
          params.channelIdEncrept = this.channelId;
          params.entId = this.undertakeData.entId;
          params.baseInfo = this.form;
          //处理数组   经营范围ID
          params.baseInfo.manageId = this.form.manageId;

          //处理企业名称
          let name,urban,range;
          //拿取经营范围和园区
          this.form.areaPre == 0 ? urban = '荆州市沙市区' :
            this.form.areaPre == 1 ? urban = '沙市区' : ''
          this.form.organizationForm == 0 ? name = '工作室' :
          this.form.organizationForm == 1 ? name = '部' :
          this.form.organizationForm == 2  ? name = '中心' : ''
          let labelOrgnameList = this.recombFun(this.form.business[0].labelOrgname);
          params.baseInfo.entName1 = urban + this.form.entName1Short + labelOrgnameList[this.form.labelOrgnameId1].value + name;
          params.baseInfo.entName2 = urban + this.form.entName2Short + labelOrgnameList[this.form.labelOrgnameId2].value + name;
          params.baseInfo.entName3 = urban + this.form.entName3Short + labelOrgnameList[this.form.labelOrgnameId3].value + name;
          params.baseInfo.entName4 = urban + this.form.entName4Short + labelOrgnameList[this.form.labelOrgnameId4].value + name;
          params.baseInfo.entName5 = urban + this.form.entName5Short + labelOrgnameList[this.form.labelOrgnameId5].value + name;
          params.baseInfo.entName1Short = this.form.entName1Short;
          params.baseInfo.entName2Short = this.form.entName2Short;
          params.baseInfo.entName3Short = this.form.entName3Short;
          params.baseInfo.entName4Short = this.form.entName4Short;
          params.baseInfo.entName5Short = this.form.entName5Short;
          params.baseInfo.areaPre = this.form.areaPre;
          params.baseInfo.mailUserAddress = this.form.mailUserAddress;
          params.baseInfo.mailUserName = this.form.mailUserName;
          params.baseInfo.mailUserPhone = this.form.mailUserPhone;
          for(var i = 1; i < 6; i++){
            params.baseInfo['labelOrgnameId'+i] = this.form['labelOrgnameId'+i];
          }
          // params.baseInfo.registerType = this.form.resource;  //注册类型:1-个体工商户2-个人独资企业3-有限公司4-合伙企业
          params.baseInfo.registerType = this.form.registerType;  //注册类型:1-个体工商户2-个人独资企业3-有限公司4-合伙企业
          params.baseInfo.serviceConfId = this.form.serviceConfId;  //企业服务模式
          params.baseInfo.protocolType = this.form.protocolType;  //企业所属合作模式:1-渠道总2-非渠道总
          params.baseInfo.registerMoney = conversionManyBranch(paramsNew.money);   //注册资金,单位分

           // 银行账户信息
          // if(this.form.protocolType == '2'){
          //   params['entBankReq'] = {...this.caiConfig.value}
          // }
          if(this.caiConfig.value.isAllEmpty == false && this.caiConfig.value.AVRes == true ){
            params['entBankReq'] = {...this.caiConfig.value}
          }
          // 经营者关联信息查询
          Object.keys(this.qoriConfig.list).forEach(key=>{
            const {fileName, url} = this.qoriConfig.list[key]
            const temp={}
            temp[`${key}List`] = [{fileName, fileUrl:url, fileType:'', valEdate:'',valSdate:''}]
            params[key] = {...temp}
          })

          //处理数组   经营范围ID
          // if (this.form.business.length > 0) {
          //   let arr = [];
          //   let business = this.form.business;
          //   for (let key in business) {
          //     if (business[key].manageId && business[key].manageId.length > 0){
          //       arr.push(filterNull(business[key].manageId))
          //     }
          //   }
          //   params.baseInfo.manageId = filterNullArr(arr);  //经营范围ID
          // }
          // console.log('@@@@@@@@@@@@@@@@@=====>',params);
          queryEntInfo(params).then(res => {
            if (res.success){
              if (res.result){
                //合作模式   总包不签署协议 分包签署协议    1-总包  2-分包
                if (this.form.protocolType == 1){
                  this.$emit('passStep');
                }else{
                  let data = res.result;
                  this.$emit('nextStep',data);
                }
              }
            }else{
              if (res.code == 516){
                this.businessInfo.visible = true;
                this.businessInfo.message = res.message;
              }else{
                this.$message.warning(res.message);
              }
            }
          })
        }
      })
    },
    //经营范围弹层--返回修改
    backEdit(){
      this.businessInfo.visible = false;
    },
    onChangeLabel(e){
      this.form.areaPre = e;
    },
    //上一步
    prevStep(){
      this.$emit('prevStep');
    },
    //重构数据
    recombFun(list){
      var obj={};
      list.map(function(e){
        obj[e.id] = {'value':e.value,'id':e.id };
      })
      return obj;
    },
    //随机生成企业名称
    autoGenerate() {
      let params = {};
      params.num = 5;
      // this.$refs.ruleForm.clearValidate();
      queryEntNames(params).then(res => {
        if (res.success) {
          if (res.result && res.result.entNames) {
            let data = res.result.entNames;
            if(!this.entNamesList){
              this.entNamesList = data;
              if(this.form.entName1Short.length<=0){
                this.form.entName1Short = data[0];
              }
              if(this.form.entName2Short.length<=0){
                this.form.entName2Short = data[1];
              }
              if(this.form.entName3Short.length<=0){
                this.form.entName3Short = data[2];
              }
              if(this.form.entName4Short.length<=0){
                this.form.entName4Short = data[3];
              }
              if(this.form.entName5Short.length<=0){
                this.form.entName5Short = data[4];
              }
            }

            let entName1Short = this.containsFun(this.entNamesList, this.form.entName1Short)
            let entName2Short = this.containsFun(this.entNamesList, this.form.entName2Short)
            let entName3Short = this.containsFun(this.entNamesList, this.form.entName3Short)
            let entName4Short = this.containsFun(this.entNamesList, this.form.entName4Short)
            let entName5Short = this.containsFun(this.entNamesList, this.form.entName5Short)
            this.entNamesList = data;
            if(this.form.entName1Short.length<=0 || entName1Short){
              this.form.entName1Short = data[0];
            }
            if(this.form.entName2Short.length<=0 || entName2Short){
              this.form.entName2Short = data[1];
            }
            if(this.form.entName3Short.length<=0 || entName3Short){
              this.form.entName3Short = data[2];
            }
            if(this.form.entName4Short.length<=0 || entName4Short){
              this.form.entName4Short = data[3];
            }
            if(this.form.entName5Short.length<=0 || entName5Short){
              this.form.entName5Short = data[4];
            }
          }
        } else {
          this.$message.warning(res.message);
        }
      })
    },
    //查询是否存在
    containsFun(arr, val) {
      if(arr && arr.length>0 && val && val.length>0){
        for (var i = 0; i < arr.length; i++) {
          if (arr[i] == val) {
            return true;
          }
        }
        return false;
      }else{
        return false;
      }

    },
    //添加经营范围
    addNatureBusiness(){
      //企业类型 1-个体工商户 2-有限公司 3-合伙企业 4-个人独资企业
      // if (this.form.resource == 4){
      //   if (this.form.business.length >= 10){
      //     this.$message.warning('经营范围最多可添加至10个')
      //   }else{
      //     this.form.business.push({});
      //   }
      // }else{
      //   if (this.form.business.length >= 5){
      //     this.$message.warning('经营范围最多可添加至5个')
      //   }else{
      //     this.form.business.push({});
      //   }
      // }
      let num = this.form.registerType == 1 ? 3 : 10;
      if (this.newTreeDataModel.length >= num) {
        this.$message.warning('经营范围最多可添加至' + num + '个');
      } else {
        this.$refs.child.add();
      }
    },
    //删除经营范围
    // deleteRateFun(index){
    //   this.form.business.splice(index, 1);
    // },
    //经营类别
    handleProvinceChange(value,index) {
      this.getLastItem(this.treeData, value, 'id',index)
      this.$forceUpdate();
    },
    // 获取点击得目标对象, key 对应得 值vals 数组（重点部分）
    getLastItem(list, vals, key,indexd) {
      let LIST = list || []
      for (let item of LIST) {
        if (item[key] === vals[vals.length - 1]) {
          //获取当前选中id值对应的对象
          this.form.business[indexd].nodeNature = item.nodeNature;
          this.form.business[indexd].invoiceName = item.invoiceName;
          this.form.business[indexd].labelEntname = item.labelEntname;
          this.form.business[indexd].labelOrgname = item.labelOrgname;
          return;
        } else {
          this.getLastItem(item.children, vals, key,indexd)
        }
      }
    },
    /**
     * 将属性结构的数据扁平化
     * */
    treeData2ObjData(treeData){
      const temp = JSON.parse(JSON.stringify(treeData))
      const getData = (treeData_)=>{
        treeData_.forEach(item=>{
          const {children,id} = item
          this.treeData[id] = item
          if(this.isType.isArray(children) && children.length>0){
            getData(children)
          }
        })
      }
      getData(temp)
    },
    //获取经营范围 废弃
    getBusinessScope(){
      const param = {
        meritoFlag: 1 //  1 主营  0 非主营
      }
      //主数据源
      getManageNature(param.meritoFlag).then(res=>{
        if (res.success) {
          let data = res.result;
          this.masterDataSource = data
          if(this.masterDataSource && this.masterDataSource.length>0){
            this.treeData2ObjData(this.masterDataSource)
          }
        }
      })

      param.meritoFlag = 0
      getManageNature(param.meritoFlag).then(res => {
        if (res.success) {
          let data = res.result;
          this.newTreeData = [...data];
          // lfh.set('newTreeData', result, 0.007) // 10分钟
          this.treeData = data || [];
          if(data&&data.length>0){
            this.treeData2ObjData(data)
          }
        } else {
          this.$message.warning(res.message);
        }
      })
    },
    //企业名称判断规则展示
    tsEntNameReg(name){
      //企业类型 1-个体工商户 2-有限公司 3-合伙企业 4-个人独资企业
      if (this.form.resource == 1){
        //判断经营类别是否选择
        // if (this.form.business[0].invoiceName) {
        if (this.form.business.length>0) {

        } else {
          this.$message.warning('请选择经营类别');
        }
      }
    },
    //限制两位小数
    limitTwoDigits(value) {
      return limitDigits(value)
    },
    // methods 正则替换小数点
    limitNumber(value) {
      if (typeof value === 'string') {
        return !isNaN(Number(value)) ? value.replace(/\./g, '') : 0
      } else if (typeof value === 'number') {
        return !isNaN(value) ? String(value).replace(/\./g, '') : 0
      } else {
        return 0
      }
    },
    //验证企业名称
    validateEnterprise(rule,value,callback){
      let reg = /^[\u4e00-\u9fa5（）()]{2,}$/gi;
      if (!value || reg.test(value)){
        this.tsEntNameReg(value);
        callback();
      }else{
        callback("您的企业名称格式不正确!");
      }
    },
  }
}
</script>

<style scoped lang="less">
h3{
  color: @color-smudge;
}
.addRange{
  cursor: pointer;
  color: @color-orange;
}

a{
  text-decoration: underline;
}

/deep/.alert .ant-col-8{
  width: 100%;
}
/deep/.ant-alert-message{
  color: #777777;
}
/deep/.ant-alert-info .ant-alert-icon{
  color: @color-blue;
}
/deep/.ant-alert-info{
  background: #F3F6FD;
  border: 1px solid #4167E8;
}

.radioGroup{
  display: flex;
  align-items: center;
}
.ant-radio-group{
  display: flex;
  align-items: flex-end;
}
.selection{
  display: flex;
  align-items: flex-end;
  .ant-select:last-child{
    margin-left: 10px;
  }
}

.entNames{
  display: flex;
  align-items: flex-start;
  white-space: nowrap;
}

/deep/.ant-form-item{
  display: flex;
  align-items: flex-start;
}
//提示经营范围有误弹层
.exceedLimit{
  width: 100%;
  padding: 20px 10px;
  color: #101010;
  h4{
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bolder;
    font-size: 20px;
    margin-left: -20px;
    margin-bottom: 20px;
    i{
      color: @color-red;
      font-size: 50px;
      margin-right: 10px;
    }
  }
  .desc_btn{
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    margin: 40px 0 20px 0;
    text-align: center;
  }
}

</style>
<style lang="less">
.enterpriseSettled-con{
  .JYFW-pro-con .pro-item .pro-item-row .pro-item-cell .item-cell.cell-label{
    max-width: 269px;
    min-width: 112px;
    flex: 2;
  }
}
</style>
